﻿using System;
using System.Linq;
using System.Collections.Generic;

using Matrix;
using Matrix.Xmpp;
using Matrix.Xmpp.Client;

namespace SBPweb.Communication.Client.Library.Xmpp.Commands
{

    partial class GetPublicConferencesCommand : Command<DiscoItemsIq, Iq>
    {

        #region Property accessors

        public List<Matrix.Xmpp.Disco.Item> ConferenceItems
        {
            get;
            protected set;
        }

        #endregion

        #region Methods

        public override DiscoItemsIq GetTypedRequest()
        {
            requestIq = new DiscoItemsIq(IqType.get);
            requestIq.To = new Jid(server);

            return requestIq;
        }

        public override void PutTypedResponse(Iq response)
        {
            base.responseIq = response;
            ConferenceItems =
                (
                from node in response.Query.Nodes()
                select (node as Matrix.Xmpp.Disco.Item)
                ).ToList<Matrix.Xmpp.Disco.Item>();
        }

        #endregion

    }

}